﻿@model Model.View_Order_Int
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    @*@Html.Partial("ViewLibrary")*@
    <title>Index</title>
    <link rel="stylesheet" type="text/css" href="~/Content/jquery-easyui-1.4.2/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="~/Content/jquery-easyui-1.4.2/themes/icon.css">
    <link href="~/Content/Styles/Order.css" rel="stylesheet" />
    <script type="text/javascript" src="~/Content/jquery-easyui-1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="~/Content/jquery-easyui-1.4.2/jquery.easyui.min.js"></script>
    <script src="~/Content/jquery-easyui-1.4.2/locale/easyui-lang-zh_CN.js"></script>
    <link href="~/Content/Styles/Order.css" rel="stylesheet" />
    <script>
        $(document).ready(function () {
            $.post("/IntegralManage/GetData",{}, function (date) {
                if (date != null) {
                    IntID = date.IntID;
                    $("#MerName").textbox("setValue", "平台积分");
                    //alert("启用：" + date.IsOpen);
                    if (date.IsOpen == 0) {
                        $("#IsOpen").attr('checked', false);
                    }
                    else
                    {
                        $("#IsOpen").attr('checked', true);
                    }
                    $("#IntUn").combobox("setValue", date.IntUn);
                    $("#IntY").combobox("setValue", date.IntY);
                    $("#IntChe").textbox("setValue", date.IntChe);
                }
                else {
                    $("#MerName").textbox("setValue", "平台积分");
                    $("#IsOpen").attr('checked', 'false');
                    $("#IntUn").combobox("setValue", "");
                    $("#IntY").combobox("setValue", "");
                    $("#IntChe").textbox("setValue",0);
                }
            });
        });

        var IntID;

        //保存
        function OnSubmit() {
            var IntUn = $('#IntUn').combobox('getValue');
            var IntY = $('#IntY').combobox('getValue');
            var IntChe = $('#IntChe').textbox('getValue');
            var IsOpen =[];
            $('input[name="IsOpen"]:checked').each(function(){
                IsOpen.push($(this).val());
            })
            //alert(IsOpen.length == 0 ? '没取到值' : IsOpen);//测试是否取到值
            if (IsOpen==1) {
                var IsOpen = 1;
            }
            else {
                var IsOpen = 0;
            }
            if (IntUn != "" && IntY != "" && IntChe != "") {
                //alert(IsOpen);
                var postdata = {
                    IntID: IntID,//积分ID
                    MerID:"0",//对应商户
                    IntUn: IntUn,//积分转换单位
                    IntY: IntY,//转换金额处理
                    IntChe: IntChe,//积分转换率
                    IsOpen: IsOpen//是否启用
                };
                $.post("/IntegralManage/Submit", postdata, function (date) {
                    if (date == "1") {
                        $.messager.alert("友情提示", "更新成功");
                    }
                    else {
                        $.messager.alert("友情提示", "修改失败，请检查");
                    }
                });
            }
            else
            {
                $.messager.alert("提示", "请输入正确的值");
            }
        }
    </script>
</head>
<body>
    <form id="editController" method="post" novalidate="novalidate">
        <div style="padding-top: 50px; text-align: center">
            <table cellpadding="2" id="IntTable" style="width: 100%; height: 100%;">
               <tr>
                   <td style="text-align:right">
                        <input type="checkbox" id="IsOpen" name="IsOpen" value ="1"/>
                    </td>
                    <td class="IntM-td-2">是否启用平台积分</td>
                </tr>
                 @* <tr>
                    <td class="IntM-td-1">积分商户：</td>
                    <td class="IntM-td-2">
                        <input class="easyui-textbox" type="text"  style="width:199px" id="MerName" name="MerName" readonly="true" />
                    </td>
                </tr>*@
                <tr>
                    <td class="IntM-td-1">积分转换单位：</td>
                    <td class="IntM-td-2">
                        <select class="easyui-combobox" type="text" style="width:199px"  id="IntUn" name="IntUn">
                            <option value="1">分</option>
                            <option value="2">角</option>
                            <option value="3">元</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="IntM-td-1">转换金额处理：</td>
                    <td class="IntM-td-2">
                        <select class="easyui-combobox"  style="width:199px" type="text" id="IntY" name="IntY">
                           <option value="1">非整数时，小数点忽略</option>
                            <option value="2">非整数时，小数点四舍五入</option>
                            <option value="3">非整数时，小数点进一</option>
                            </select></td>
                </tr>
                <tr>
                    <td class="IntM-td-1">积分转换率：</td>
                    <td class="IntM-td-2">
                        <input class="easyui-textbox"  style="width:199px" type="text" id="IntChe" name="IntChe" />
                    </td>
                </tr>
                <tr>
                     <td>
                        </td>
                    <td style="text-align:left;">
                         <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" id="ok" onclick="OnSubmit()">确认</a>
                    </td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>
